package string;

/**
 * String支持正则表达式的方法
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        //将数字替换
        String str = "abc123def456ghi";
        str = str.replaceAll("[0-9]+" ,"NUMBER");
        System.out.println(str);

        //将字母替换
        String arr = "abc123def456ghi";
        str = str.replaceAll("[a-z]+" ,"NUMBER");
        System.out.println(str);

        //和谐用语
        String regex = "(wqnmlgb|dsb|cnm|nt|nmsl|wrsndm|djb|sb)";
        String message = "wrsndm!你个dsb!你也太sb了,你个djb!你妈sl!";
        message = message.replaceAll(regex,"******");
        System.out.println(message);



    }
}
